package com.yaodian100.ec.member.entity;

import java.math.BigDecimal;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import com.yaodian100.core.common.entity.BaseEntity;

@Entity
@Table(name = "EC_MEMBER_VIRTUAL_BALANCE")
public class VirtualBalance extends BaseEntity {
	/*
	 * 1、订单退款=>orders(正向) 2、提现失败=>提领单据(正向) 3、提现申请=>提领单据(负向)
	 */
	public enum VirtualBalanceType {
		/** 订单退款 */
		EC_ORDER_MAIN,
		/** 提现失敗/申請 */
		ORDER,
		/** 活动赠送 */
		ACTIVE
	}

	public enum VirtualBalancePayType {
		VirtualBalance("V"), GiftcardBalance("G");
		String value;

		VirtualBalancePayType(String bean) {
			this.value = bean;
		}

		public String getValue() {
			return this.value;
		}
	}

	private static final long serialVersionUID = -4025741637359232695L;;

	/**
	 * 流水號
	 */
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO, generator = "seq_ec_member_virtual_balance")
	@SequenceGenerator(name = "seq_ec_member_virtual_balance", sequenceName = "SEQ_EC_MEMBER_VIRTUAL_BALANCE")
	@Column(name = "ID")
	private Long id;

	/**
	 * 會員編號
	 */
	@Column(name = "MEMBER_ID", nullable = false, length = 10)
	private String memberId;

	/**
	 * 我的帐户类别(匯入/提領類型)
	 */
	@Enumerated
	@Column(name = "TRX_TYPE", length = 20, updatable = false, nullable = false)
	private String trxType;

	/**
	 * 我的帐户类别id
	 */
	@Column(name = "TRX_TYPE_ID", nullable = false, length = 17)
	private String trxTypeId;

	/**
	 * 帳戶金額
	 */
	@Column(name = "TRX_AMOUNT", columnDefinition = "numeric(10,2)")
	private BigDecimal trxAmount;

	/**
	 * 我的帐户產生日期
	 */
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "TRX_DATE", nullable = false)
	private Date trxDate;

	/**
	 * 交易說明
	 */
	@Column(name = "DESCRIPTION", length = 300)
	private String description;

	/**
	 *小计
	 */
	@Column(name = "SUMMARY_AMOUNT", columnDefinition = "numeric(10,2)")
	private BigDecimal summaryAmount;

	/**
	 * 財會核可日期
	 */
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "APPROVE_DATE")
	private Date approveDate;

	/**
	 * 類型
	 */
	@Column(name = "type", length = 1, nullable = false)
	private String type = VirtualBalancePayType.VirtualBalance.getValue();

	public String getDescription() {
		return description;
	}

	public Long getId() {
		return id;
	}

	public String getMemberId() {
		return memberId;
	}

	public BigDecimal getSummaryAmount() {
		return summaryAmount;
	}

	public BigDecimal getTrxAmount() {
		return trxAmount;
	}

	public Date getTrxDate() {
		return trxDate;
	}

	public String getTrxType() {
		return trxType;
	}

	public String getTrxTypeId() {
		return trxTypeId;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public void setMemberId(String memberId) {
		this.memberId = memberId;
	}

	public void setSummaryAmount(BigDecimal summaryAmount) {
		this.summaryAmount = summaryAmount;
	}

	public void setTrxAmount(BigDecimal trxAmount) {
		this.trxAmount = trxAmount;
	}

	public void setTrxDate(Date trxDate) {
		this.trxDate = trxDate;
	}

	public void setTrxType(String trxType) {
		this.trxType = trxType;
	}

	public void setTrxTypeId(String trxTypeId) {
		this.trxTypeId = trxTypeId;
	}

	public Date getApproveDate() {
		return approveDate;
	}

	public void setApproveDate(Date approveDate) {
		this.approveDate = approveDate;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}
}